﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Lon.Server
{
    public  interface IDataStoreModule
    {
        
    }
    public  class CsmClient
    {
        public String Dbm;
        public int Id;
        public String Ip;
        public FrontServerClient connectClient;
        public IDataStoreModule dataStoreModule;
        private DateTime lastStateTime;
        private bool connectedState=false;
   
      

        public bool ConnectedState
        {
            get
            { 
                if (connectedState == false) return false;
                if (connectClient == null) return false;
                if (connectClient.ClientSocket == null) return false;
                if (connectClient.ClientSocket.Connected == false) return false;
                if ((DateTime.Now - lastStateTime).TotalSeconds < 30) return true;
               
              
                connectedState = false;
                return false;
            }
           
        }

        public DateTime LastStateTime
        {
            get { return lastStateTime; }
   
        }

        public void SendBuf(byte[] buf)
        {
            if (connectClient == null) return;
            connectClient.RealSend(buf);
        }

        public void SendDataFrame(DataFrame df)
        {
            if (this.connectClient == null) return;
            if (this.ConnectedState == false) return;
            df.DstId = this.Id;      
            this.connectClient.RealSend(df.Buf);
            
        }   
        
    }

    public class StationClient:CsmClient
    {

        public void SaveFile(String fileName,UInt32 fileTime,UInt32 fileChangeTime)
        {

        }
       
    }

    public class VerMessage
    {
        public DataFrame lastUpdateFrame=null;
        /// <summary>
        /// 机器名
        /// </summary>
        public String ComputorName { get; set; }
        /// <summary>
        /// 操作系统版本
        /// </summary>
        public String SystemVer { get; set; }
        /// <summary>
        /// 软件版本
        /// </summary>
        public String SoftVer { get; set; }



    }


    

    public abstract class DataFrameParser
    {
        protected byte funCode;
        public abstract byte FunCode{get;}
        public abstract void Parse(DataFrame df);    
    }

    

    
 
}
